<template>
  <a-modal
    :visible="open"
    title="资产详情"
    width="60%"
    @ok="onClose"
    @cancel="onClose"
  >
    <a-descriptions>
      <a-descriptions-item label="资产名称1">{{ asset.assetName }}</a-descriptions-item>
      <a-descriptions-item label="资产编码">{{ asset.assetCode }}</a-descriptions-item>
      <a-descriptions-item label="RFID芯片码">{{ asset.assetEpc }}</a-descriptions-item>
      <a-descriptions-item label="所属客户">{{ asset.clientName }}</a-descriptions-item>
      <a-descriptions-item label="所在楼层">{{ asset.assetFloor }}</a-descriptions-item>
      <a-descriptions-item label="所在库房">{{ asset.assetPosition }}</a-descriptions-item>
      <a-descriptions-item label="资产位置" :span="2">
        {{ asset.address }}
      </a-descriptions-item>
      <a-descriptions-item label="盘点状态">{{ asset.inventoryStatus }}</a-descriptions-item>
    </a-descriptions>
    <a-timeline title="啊啊啊">

      <a-timeline-item v-for="item in lifecycleList">
        <p style="color:#aaa">{{ item.eventTime }}</p>
        <p>{{ item.content }}</p>
      </a-timeline-item>
    </a-timeline>
  </a-modal>
</template>
<script lang="ts" setup>
import {
  computed,
  defineProps,
  onMounted,
  ref,
  unref,
  defineEmits,
  reactive,
  type PropType
} from "vue";
import {
  type AssetBo,
  type AssetPageVo, type AssetSo,
  type ClientVo,
  type FloorVo, lifecycleApi, type LifecycleVo,
  listClientApi, listFloorApi, listPositionApi,
  pageAssetApi, type PositionVo, submitTransferApi
} from "#/api";
import {message} from "ant-design-vue";
import {SearchOutlined} from "@ant-design/icons-vue";

const props = defineProps({
  open: {
    type: Boolean,
    required: true,
    default: false,
  },
  asset: {
    type: Object,
    required: true,
  }
});
const emit = defineEmits(['close'])


const loading = ref<boolean>(false);
const dataSource = ref<AssetPageVo[]>([]);
const lifecycleList = ref<LifecycleVo[]>([]);

const onClose = () => {
  console.log('close')
  emit('close')
}


onMounted(() => {
  list();
})

const handleTransferSubmit = async () => {
  console.log('targetKeys', targetKeys.value)
  transferBo.assets.push(...targetKeys.value)
  console.log('transferBo', transferBo)
  const res = await submitTransferApi(transferBo)
  message.success("调拨成功")
  emit('close')
}

const list = async () => {
  if (props.asset.id != undefined) {
    const res = await lifecycleApi({
      assetId: props.asset.id
    })
    lifecycleList.value = res
  }
}
</script>
